<?php

class Application_Form_Contato extends Zend_Form
{

    public function init()
    {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $url = $front->getBaseUrl().'/'.$controller;
        
        $this->setName('form_'.$controller);
        
        //$this->setAction($url.'/enviar');
        
        $el = new Zend_Form_Element_Text('nome');
        $el->setLabel('Nome:')
                ->setRequired(true)
                ->addFilters(array('StringTrim','StripTags'))
                ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('email');
        $el->setLabel('E-mail:')
                ->setRequired(true)
                ->addFilters(array('StringTrim','StripTags'))
                ->addValidator('EmailAddress', TRUE )
                ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('telefone');
        $el->setLabel('Telefone:')
                ->setRequired(true)
                ->addFilters(array('StringTrim','StripTags'))
                ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('cidade');
        $el->setLabel('Cidade:')
        ->setRequired(true)  
        ->setAttrib('class', 'cidade')    
        ->setDescription('<label>UF:</label><input type="text" value="" id="uf" name="uf" class="uf" maxlength="2" />')
        ->setDecorators(array('ViewHelper',
        array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'dd')),
        array('Label', array('tag' => 'dt')),
        'Errors',))
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Text('assunto');
        $el->setLabel('Assunto:')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Textarea('mensagem');
        $el->setLabel('Mensagem:')
        ->setRequired(true)
        ->addFilters(array('StringTrim','StripTags'))
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Button('submit');
        $btn->setLabel('Enviar');
        $btn->setAttrib('type', 'submit')
        ->setDecorators(array('ViewHelper',
        array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'dd','id'=>'submit-element')),'Errors'));
        $this->addElement($btn);
        
    }


}

